package pers.cj.pdos.service;

import org.apache.ibatis.annotations.Param;
import pers.cj.pdos.entity.*;
import com.baomidou.mybatisplus.extension.service.IService;
import pers.cj.pdos.vo.GoodsVo;

import java.util.List;
import java.util.Map;

/**
 * <p>
 *  服务类
 * </p>
 *
 * @author chenj
 * @since 2019-11-04
 */
public interface IGoodsService extends IService<Goods> {
    List<Goods> list(String companyId);

    List<GoodsVo> listVoByIds(List<String> ids);

    List<GoodsVo> listVoForCheckHouse(String companyId,
                                      Integer page,
                                      Integer limit,
                                      Integer status ,
                                      String search,
                                      String typeId,
                                      String no,
                                      String name,
                                      String attr,
                                      String norms,
                                      String remark,
                                      Boolean sn,
                                      String houseId);

    List<GoodsVo> listVoWithStockPage(String companyId,
                             Integer page,
                             Integer limit,
                             Integer status ,
                             String search,
                             String typeId,
                             String no,
                             String name,
                             String attr,
                             String norms,
                             String remark,
                             Boolean sn,
                             String houseId);


    List<GoodsVo> listVoForInit(String companyId,
                                Integer page,
                                Integer limit,
                                String search,
                                String storeId,
                                String houseId);
    Long countForInit(String companyId,
                      String search,
                      String storeId,
                      String houseId);


    List<GoodsVo> listVoPage(String companyId,
                             Integer page,
                             Integer limit,
                             Integer status ,
                             String search,
                             String typeId,
                             String no,
                             String name,
                             String attr,
                             String norms,
                             String remark,
                             Boolean sn);
    long count(String companyId,
               Integer status ,
               String search,
               String typeId,
               String no,
               String name,
               String attr,
               String norms,
               String remark,
               Boolean sn);

    GoodsVo getVoById(String id);

    boolean check(String id);
    Map<String,Long> check(List<Goods> goodsList);

    void save(Goods goods, List<GoodsAttr> goodsAttrList, List<GoodsUnit> goodsUnitList,
              List<GoodsHouseWarn> goodsHouseWarnList,List<GoodsInit> goodsInitList,
              List<GoodsSn> goodsSnList,List<GoodsSnLog> goodsSnLogList);

    void update(Goods goods, List<GoodsAttr> goodsAttrList, List<GoodsUnit> goodsUnitList,
                List<GoodsHouseWarn> goodsHouseWarnList,List<GoodsInit> goodsInitList,
                List<GoodsSn> goodsSnList,List<GoodsSnLog> goodsSnLogList);


    boolean checkName(String companyId, String id, String name);

    boolean checkNo(String companyId, String id, String no);

    void remove(Goods goods);

    /**
     * 批量导入商品
     * @param goodsList
     * @param typeList
     * @param unitList
     * @param attrList
     * @param goodsAttrList
     * @param goodsUnitList
     * @param goodsHouseWarnList
     */
    void insert(List<Goods> goodsList, List<Type> typeList, List<Unit> unitList, List<Attr> attrList, List<GoodsAttr> goodsAttrList, List<GoodsUnit> goodsUnitList, List<GoodsHouseWarn> goodsHouseWarnList);

    /**
     * 批量开启sn
     * @param goodsList
     */
    void batchOpenSn(List<Goods> goodsList);

    /**
     * 批量修改状态
     * @param goodsList
     * @param status 1-开启 2-停用
     */
    void batchStatus(List<Goods> goodsList, Integer status);

    /**
     * 批量移动至分类
     * @param goodsList
     * @param typeId
     */
    void batchMoveType( List<Goods> goodsList, String typeId);

    /**
     * 批量删除
     * @param goodsList
     */
    void batchDelete( List<Goods> goodsList);

    GoodsVo getVoByCode(String code,String companyId);

    /**
     * 是否被套餐使用
     * @param id
     * @return
     */
    boolean beUsedByPacket(String id);

    /**
     * 检查条码是否被使用
     * @param companyId
     * @param codeList
     * @return
     */
    Long checkCodeListBeUsed(String companyId, String id, List<String> codeList);
}
